package Graph;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class 所有可达路径 {
    static int n = 0;
    static List<List<Integer>> res = new ArrayList<>();
    static List<Integer> path = new ArrayList<>();

    public static void main (String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        int m = in.nextInt();
        boolean[][] graph = new boolean[n + 1][n + 1];
        for (int i = 0; i < m; i++) {
            graph[in.nextInt()][in.nextInt()] = true;
        }
        path.add(1);
        dfs(graph, 1);
        if (res.isEmpty()){
            System.out.println(-1);
        }
        for (List<Integer> list : res) {
            for (int i = 0; i < list.size() - 1; i++) {
                System.out.print(list.get(i) + " ");
            }
            System.out.println(list.getLast());
        }
    }

    private static void dfs(boolean[][] graph, int cur) {
        if (cur == n) {
            res.add(new ArrayList<>(path));
            return;
        }
        for (int i = 1; i <= n; i++) {
            if (graph[cur][i]) {
                path.add(i);
                dfs(graph, i);
                path.removeLast();
            }
        }
    }
}
